package com.suray.system.run.seer.util;

import com.suray.commin.core.utils.SpringContextHolder;
import com.suray.system.run.seer.mysql.PointMapDB;
import com.suray.system.run.seer.mysql.PointMapServiceImpl;

import java.util.List;

public class PointManage {

    private static PointMapServiceImpl portMapService = SpringContextHolder.getBean(PointMapServiceImpl.class);

    /**
     * 更新点位信息
     * @param point
     * @return
     */
    public static boolean updatePoint(PointMapDB point) {
        return portMapService.updateById(point);
    }

    /**
     * 获取库内点位
     * @return
     */
    public static List<PointMapDB> getAllPointMapDBCloseRgv() {
        return portMapService.findPointMapDBCloaseRgv();
    }

    /**
     * 查找点位外面的点
     * @param point：AGV点位
     * @return
     */
    public static String findOutPoint(String point) {
        PointMapDB pointMapDB = portMapService.getPortMapByAgvNode(point);
        return pointMapDB.getNearPoint();
    }

    public static String getAgvNodeByWmsNode(String wmsNode) throws NullPointerException {
        PointMapDB portMapDB = portMapService.getPortMapByWmsNode(wmsNode);
        return portMapDB.getAgvPoint();
    }

    public static String getAgvNodeByMapNode(String mapNode) throws NullPointerException {
        PointMapDB portMapDB = portMapService.getPortMapByMapNode(mapNode);
        return portMapDB.getAgvPoint();
    }

    public static String getPlcNodeByWmsNode(String wmsNode) {
        try {
            PointMapDB portMapDB = portMapService.getPortMapByWmsNode(wmsNode);
            return portMapDB.getPlcPoint();
        } catch (Exception e) {
            throw e;
        }
    }

    public static String getPlcNodeByAgvNode(String agvNode) {
        PointMapDB portMapDB = portMapService.getPortMapByAgvNode(agvNode);
        return portMapDB.getPlcPoint();
    }

    public static PointMapDB getPortMapByAgvNode(String agvNode) {
        return portMapService.getPortMapByAgvNode(agvNode);
    }

    public static PointMapDB getPortMapByPlcNode(String plcNode) {
        return portMapService.getPortMapByPlcNode(plcNode);
    }

    public static PointMapDB getPortMapByWmsNode(String wmsNode) {
        return portMapService.getPortMapByWmsNode(wmsNode);
    }

    public static PointMapDB getPortMapByMapNode(String mapNode) {
        return portMapService.getPortMapByMapNode(mapNode);
    }

}
